home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Newsflash issue 2 disk 1.adf / PROG / cmd_player.c.pp / cmd_player.c
C/C++ Source or Header  |  1990-01-23  |  2KB  |  69 lines

  1.     
  2. /************************************************************************/
  3. /************************************************************************/
  4.  
  5. #include <stdio.h>
  6. #include <rexx/storage.h>
  7. #include <rexx/errors.h>
  8.  
  9. char    *portname="Multi_Player";
  10.  
  11. /***********************/
  12. /* PROGRAMME PRINCIPAL */
  13. /***********************/
  14.  
  15. main(argc,argv)
  16. int   argc;
  17. char  **argv;
  18.  
  19. {
  20.   if(argc>1){
  21.     if(send_msg(argv[1])!=0){
  22.         exit(-1);
  23.     }
  24.   }else{
  25.     printf("usage:  cmd_player <cmd_name>\n");
  26.     printf("Cmd name can be: Play <module name>->load and play a song\n");
  27.     printf("               : Stop              ->stop the song\n");
  28.     printf("               : Start             ->restart a stopped song\n");
  29.     printf("               : Select <song num> ->select a song, only with TFMX\n");
  30.     printf("               : Quit             ->stop the player\n");
  31.   }
  32.   exit(0);
  33. }
  34.  
  35. send_msg(buf)
  36. char *buf;
  37. {
  38.     struct    RexxMsg    rx_message;
  39.     struct    MsgPort *rexx_port = NULL;
  40.     struct    MsgPort *reply_port = NULL;
  41.     int    code_ret;
  42.  
  43.     code_ret=0;
  44.     Forbid();
  45.     if( (rexx_port=FindPort (portname)) ==NULL){
  46.         printf("Multi player not found!\n");
  47.         Permit();
  48.         code_ret=-1;
  49.     }else if((reply_port=(struct MsgPort *)CreatePort ("Reply port", 0L))==NULL){
  50.         printf("Cannot create replay port!\n");
  51.         Permit();
  52.         code_ret=-1;
  53.     }else{
  54.         rx_message.rm_Args[0]=buf;
  55.         rx_message.rm_Args[1]=NULL;
  56.         rx_message.rm_Args[2]=NULL;
  57.         rx_message.rm_Action=RXCOMM;
  58.         rx_message.rm_Node.mn_ReplyPort=reply_port;
  59.         rx_message.rm_Node.mn_Node.ln_Type=NT_MESSAGE;
  60.  
  61.         PutMsg(rexx_port,&rx_message);
  62.         Permit();
  63.         WaitPort(reply_port);
  64.         DeletePort(reply_port);
  65.         if(rx_message.rm_Result1!=RC_OK)code_ret=-1;
  66.     }
  67.     return(code_ret);
  68. }
  69.